package com.huangpeng.algorithm.species51;

import java.util.Scanner;

/**
 * @Author huangpeng
 * @Title 河内之塔（汉诺塔）
 * @Package
 * @Date 2021/5/13 19:04
 * @Description
 * @Version 1.0
 */
public class HanoiTower {

    public static void hanoi(int n,String A,String B,String C){
        if(n == 1){
            System.out.println("Move sheet " + n + " from " + A + " to " + C);
        }else{
            hanoi(n-1,A,C,B);
            System.out.println("Move sheet " + n + " from " + A + " to " + C);
            hanoi(n-1,B,A,C);
        }
    }

    public static void main(String[] args) {
        System.out.println("请输入一个数n=");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        HanoiTower.hanoi(n,"A","B","C");
    }
}
